package com.zoo.curator.impl;

import com.zoo.curator.AbstractCurator;
import com.zoo.curator.AbstractLeaderSelectorClient;
import org.apache.curator.framework.CuratorFramework;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by Administrator on 2015/10/30.
 */
public class LocalLeaderSelectorClient extends AbstractLeaderSelectorClient {
    public static final Logger LOGGER = LoggerFactory.getLogger(LocalLeaderSelectorClient.class);

    public LocalLeaderSelectorClient(AbstractCurator curator, String name) {
        super(curator, name);
    }

    public void takeLeadership(CuratorFramework curatorFramework) throws Exception {
        LOGGER.info(name + ",成为leader,开始启动进程");
        try{
            curator.startProcess(null);
        }catch (Exception e){
            LOGGER.error("释放LEADER权限异常",e);
        }finally{
            LOGGER.info("释放LEADER权限");
        }
    }
}
